#include "IWD.h"
const double IWD::As = 1.0;
const double IWD::Av = 1.0;
const double IWD::Bs = 0.01;
const double IWD::Bv = 0.01;
const double IWD::Cs = 1.0;
const double IWD::Cv = 1.0;

const double IWD::InitVel = 200.0;

IWD::IWD( Cluster * c1, int Nc )
{
	this->soil = 0.0;
	this->velocity = InitVel;
	this->vis[c1] = (Service *)c1->memberServices[rand() % c1->memberServices.size()];
}

double IWD::updateSoil(double time)
{
	double deltaSoil;
	deltaSoil = As/(Bs + Cs*time*time);
	soil += deltaSoil;
	return deltaSoil;
}

void IWD::updateVelocity(double pathSoil)
{
	velocity += Av/(Bv + Cv*pathSoil*pathSoil);
}

double IWD::moveTo( Service *s1, double pathSoil, double HUDresult )
{
	updateVelocity(pathSoil);
	double time = HUDresult/velocity;
	double deltaSoil = updateSoil(time);
	vis[(Cluster *)s1->cluster] = s1;
	return deltaSoil;
}
